cmake_minimum_required(VERSION 3.5.1)
project(op_gelu_ctyun_dsl)


add_compile_options(-std=c++11)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

if(NOT "$ENV{ASCEND_CUSTOM_PATH}" STREQUAL "")      
    set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
else()
    set(ASCEND_PATH $ENV{ASCEND_HOME})
endif()
set(INCLUDE_BASE_DIR "${ASCEND_PATH}/include")
include_directories(
    ${INCLUDE_BASE_DIR}
    ${INCLUDE_BASE_DIR}/aclnn
    inc
)

file(GLOB CPP_SOURCES src/*.cpp)

set(LIB_PATH $ENV{NPU_HOST_LIB})
if (NOT DEFINED ENV{NPU_HOST_LIB})
    set(LIB_PATH "${ASCEND_HOME}/runtime/lib64/stub/")
    message(STATUS "set default LIB_PATH: ${LIB_PATH}")
else ()
    message(STATUS "env LIB_PATH: ${LIB_PATH}")
endif()

include_directories(${INC_PATH} inc)
link_directories(${LIB_PATH})
add_executable(gelu_ctyun_dsl ${CPP_SOURCES})
target_link_libraries(gelu_ctyun_dsl ascendcl stdc++)

install(TARGETS gelu_ctyun_dsl DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
